from concurrent.futures import ProcessPoolExecutor
import multiprocessing
import time


def action(num):
    print(multiprocessing.current_process().name)
    time.sleep(num)
    return num + 100

if __name__=="__main__":
    with ProcessPoolExecutor(max_workers=3) as pool:
        future1 = pool.submit(action, 3)
        future1.result()
        print(f"单个任务返回:{future1.result()}")

        print("---------")
        #使用线程执行map计算
        results = pool.map(action, [1, 3, 5])
        for r in results:
            print(f"多个任务返回:{r}")